﻿using Digitalmes.Application.Sys.Users.Services;

namespace Digitalmes.Application.Sys.Users.Queries;

/// <summary>
/// 查询用户拥有的权限代码命令。
/// </summary>
/// <param name="UserId"></param>
public record GetPermissionCodesOfUserQuery(long UserId) : IRequest<IResult<string[]>>;

internal sealed class GetPermissionCodesOfUserQueryHandler(IUserMenuApplicationService service) : IRequestHandler<GetPermissionCodesOfUserQuery, IResult<string[]>>
{
    public async Task<IResult<string[]>> Handle(GetPermissionCodesOfUserQuery request, CancellationToken cancellationToken)
    {
        var codes = await service.GetPermissionCodesByUserIdAsync(request.UserId);
        return Result.From(codes);
    }
}
